package com.bsj.travel.def.monitor.tdengine;

import com.bsj.travel.constant.TdEngineDataConstants;
import lombok.Data;

import java.sql.SQLException;
import java.util.List;

/**
 * @author yinhao
 * @version 1.0
 * @description 超级表创建实体
 * @date 2024/1/31
 */
@Data
public class SuperTable {
    /**
     * 字段值
     */
    private List<FieldsVo> schemaFields;
    /**
     * tag值
     */
    private List<FieldsVo> tagsFields;
    /**
     * 库名
     */
    private String dataBaseName;

    /**
     * 超级表名
     */
    private String superTableName;

    public void transLogSuperTs(String productKey) throws SQLException {
        this.superTableName = TdEngineDataConstants.T_LOG + productKey;
        List<Fields> fieldsList = List.of(new Fields("ts", "timestamp", null),
                new Fields("traceId", "string", 64),
                new Fields("serveType", "int", 2),
                new Fields("operate", "string", 64),
                new Fields("content", "varchar", 32768),
                new Fields("code", "int", 11));
        this.schemaFields = FieldsVo.fieldsTranscoding(fieldsList);
        List<Fields> tagFieldsList = List.of(new Fields("event", "string", 64));
        this.tagsFields = FieldsVo.fieldsTranscoding(tagFieldsList);
    }
}
